package com.gzu.live.controller;

import com.gzu.live.pojo.Live;
import com.gzu.live.service.LiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
//直播间控制类
@RestController
@RequestMapping("/live")
public class LiveController {
    @Autowired
    private LiveService liveService;
    //查询所有直播间信息用于展现直播列表
    @GetMapping("/findAll")
    public List<Live> getLiveList(){
        System.out.println(liveService.findLiveList());
        return liveService.findLiveList();

    }
    //创建直播间
    @PostMapping("/createLive")
    public void addLive(Live live)
    {
        liveService.addLive(live);
    }
    //更新直播间信息
    @PutMapping("/updateLive/{userId}")
    public void updateLiveById(@PathVariable("userId") int userId){
        liveService.updateLiveById(userId);
    }
    //删除直播间信息
    @DeleteMapping("/deleteLive/{userId}")
    public void deleteById(@PathVariable("userId") int userId){
        liveService.deleteById(userId);
    }
    @PostMapping("/uploadCover")
    public String uploadCover(MultipartFile file){
        return liveService.uploadCover(file);
    }
}
